<template>
  <div>
    <jgSearch
      :searchData="searchData"
      @on-change-change="askDataing"
      @on-change-changes="getDatas"
      @on-enter-input="inputaskData"
      @on-clear-input="inputaskData"
    >
      <template v-slot:preArrivalradio>
        <RadioGroup type="button" v-model="type" @on-change="changetype(type)">
          <Radio :label="2">今</Radio>
          <Radio :label="3">明</Radio>
          <Radio :label="4">周</Radio>
          <Radio :label="5">月</Radio>
        </RadioGroup>
      </template>
      <template v-slot:department>
        <Select
          placeholder="选择部门"
          v-width="120"
          clearable
          @on-change="changeDept"
          v-model="params.department_id"
        >
          <Option
            :value="+item.value"
            v-for="item in belongData"
            :key="item.value"
            >{{ item.label }}</Option
          >
        </Select>
      </template>
      <template v-slot:belong>
        <Select
          placeholder="归属人"
          v-model="belong_member_id"
          multiple
          filterable
          @on-change="askDataing"
        >
          <Option
            :value="item.value"
            v-for="item in menberList"
            :key="item.value"
            >{{ item.label }}</Option
          >
        </Select>
      </template>
      <template v-slot:city>
        <!-- <Select
                    v-model="area_code"
                    placeholder="请输入城市"
                    filterable
                    remote
                    clearable
                    :remote-method="remoteMethod"
                    @on-change="getDatas"
                    :loading="loadingcity"
                >
                    <Option
                        v-for="(item, index) in optionscity"
                        :key="index"
                        :value="item.value"
                        :label="item.label"
                        >{{ item.label }}</Option
                    >
                </Select> -->
        <jgcheckcity
          ref="checkcity"
          @cityvalue="cityvalue"
          v-model="area_code"
          name="preArrivalpatient"
        ></jgcheckcity>
      </template>
    </jgSearch>
    <tablelist
      @askData="askDatas"
      :params="params"
      :columns="columns"
      :list="list"
      :loading="loading"
      :total="total"
      currentTab="preArrival"
    ></tablelist>
  </div>
</template>
<script>
import { patientindexorderarrivelist } from "@/api/hqapi";
import jgSearch from "@/components/search";
// import jgcheckcity from '@/components/checkcity';
import tablelist from "./tablelist";
import mixins from "./mixins";
export default {
  name: "preArrivalpatient",
  components: { tablelist, jgSearch },
  mixins: [mixins],
  data() {
    return {
      searchData: {
        project: [
          { id: 2, key: "slot", keys: "preArrivalradio" },
          {
            id: 4,
            key: "DatePicker",
            transfer: true,
            format: "yyyy-MM-dd",
            placeholder: "请选择预到时间",
            options: {
              disabledDate(date) {
                return date && date.valueOf() < Date.now() - 24 * 3600000;
              },
            },
            style: { width: "200px" },
            value: [new Date(), new Date()],
            type: "daterange",
            callback: "changes",
          },
          {
            id: 5,
            key: "Input",
            placeholder: "请输入患者姓名/手机号/微信号/唯一身份",
            clearable: true,
            style: { width: "270px" },
            value: "",
            callback: "input",
          },
          { id: 7, key: "slot", keys: "department" },
          { id: 11, key: "slot", keys: "belong" },
          // { id: 7, key: 'Select', transfer: true, style: { minWidth: '200px' },multiple: true, placeholder: '归属人', Group: true, value: '', childList: [], clearable: true, callback: 'change' },
          {
            id: 8,
            key: "TreeSelect",
            transfer: true,
            style: { minWidth: "100px" },
            placeholder: "病种",
            value: "",
            childList: [],
            clearable: true,
            callback: "change",
          },
          {
            id: 12,
            key: "Select",
            transfer: true,
            style: { minWidth: "100px" },
            placeholder: "对话方式",
            value: "",
            childList: [],
            clearable: true,
            callback: "change",
          },
          {
            id: 20,
            key: "Select",
            transfer: true,
            style: { minWidth: "100px" },
            placeholder: "部位",
            multiple: true,
            maxTagCount: 3,
            value: [],
            childList: [],
            clearable: true,
            callback: "change",
          },
          {
            id: 9,
            key: "TreeSelect",
            transfer: true,
            maxTagCount: 3,
            style: { minWidth: "100px" },
            placeholder: "渠道来源",
            multiple: true,
            value: [],
            childList: [],
            clearable: true,
            callback: "change",
          },
          { id: 13, key: "slot", keys: "city" },
          // { id: 11, key: 'Select', style: { minWidth: '100px' }, placeholder: '城市', value: '', childList: [], clearable: true, callback: 'change'},
        ],
      },
      options: {
        disabledDate(date) {
          return date && date.valueOf() > Date.now();
        },
      },
      columns: [
        {
          title: "基本信息",
          key: "basic",
          slot: "info",
          width: 135,
          fixed: "left",
        },
        { title: "患者状态", key: "state", slot: "state", width: 100 },
        { title: "归属人", key: "realname", width: 120 },
        {
          title: "预到时间",
          key: "appointment_time_str",
          sortable: "custom",
          width: 108,
        },
        {
          title: "回访次数",
          key: "callback_count",
          sortable: "custom",
          width: 108,
        },
        {
          title: "未访天数",
          sortable: "custom",
          key: "uncallback_day",
          filteredValue: [],
          filters: [
            {
              label: "0-10天未访",
              value: "1",
            },
            {
              label: "11-20天未访",
              value: "2",
            },
            {
              label: "21-30天未访",
              value: "3",
            },
            {
              label: "31-60天未访",
              value: "4",
            },
            {
              label: "60天以上未访",
              value: "5",
            },
          ],
          filterMultiple: false,
          filterRemote(value) {
            this.filterType = value[0];
          },
          width: 130,
        },
        { title: "部位", slot: "labels", width: 200 },
        {
          title: "未到天数",
          key: "belong_assign_time_day",
          sortable: "custom",
          width: 108,
        },
        { title: "患者标签", key: "label", slot: "label", width: 260 },
        {
          title: "城市",
          key: "city_name",
          width: 200,
        },
        { title: "病种", slot: "disease", width: 200 },
        { title: "对话方式", key: "dialog_mode_name", width: 108 },
        {
          title: "来源",
          width: 120,
          key: "source_name",
          slot: "channel",
          sortable: "custom",
        },
        {
          title: "创建时间",
          key: "created_at_str",
          sortable: "custom",
          width: 135,
        },
        {
          title: "备注",
          minWidth: 250,
          key: "remark",
          ellipsis: true,
          tooltip: true,
        },
        { title: "操作", width: 145, slot: "action", fixed: "right" },
      ],
      filterType: "",
    };
  },
  methods: {
    askData() {
      this.loading = true;
      this.getparams();
      let params = JSON.parse(JSON.stringify(this.params));
      // params.area_code = this.area_code
      patientindexorderarrivelist(params).then((res) => {
        this.list = res.list;
        if (+this.params.page === 1) this.total = res.total;
        this.$emit("alltotal", { key: "order_arrive", total: res.total });
        this.loading = false;
      });
    },
  },
};
</script>
